<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <p>点击按钮获取数组元素的平方根</p>
    <button onclick="myFunction()">点我</button>
    <p id="demo"></p>

    <script>
        var arr = [23,21,9];
//         区别:
// 1、.forEach(没有返回值,改变原数组
// 2、.map()有返回值,返回新数组,原数组不变

        function myFunction(){
            x = document.getElementById('demo');
            x.innerHTML = arr.map(Math.sqrt);
        } 
    </script>
</body>
</html>